﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_Home : System.Web.UI.Page
{
    private int numberOfProducts = 6;
    private StoreApplicationService sas = new StoreApplicationService();

    protected void Page_Load(object sender, EventArgs e)
    {
        using (var bd = new Store.DateModel.StoreDBEntitiesConnection())
        {
            if (!Page.IsPostBack)
            {
                //TODO: SELECT THE newest 6 products
                var query = sas.GetNewestProducts(numberOfProducts);

                ProductsRepeter.DataSource = query;
                ProductsRepeter.DataBind();


                query = sas.GetMostPopularProducts(3);
                if (query.Count > 0)
                {
                    ProduseRecomandate.DataSource = query;
                    ProduseRecomandate.DataBind();
                }
            }

        }

    }
    protected void ProduseRecomandate_ItemCommand(object source, RepeaterCommandEventArgs e)
    {

    }
}